* (bug 5523) $wgNoFollowNsExceptions to allow disabling rel="nofollow" in specially...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 22 May 2006 21:17:38 +0000 (21:17 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 22 May 2006 21:17:38 +0000 (21:17 +0000)
Patch by Ilmari Karonen, http://bugzilla.wikimedia.org/attachment.cgi?id=1789&action=view

RELEASE-NOTES
includes/DefaultSettings.php
includes/Linker.php
includes/Parser.php

index 15603fa..ffae1a7 100644 (file)
@@ -313,6 +313,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   look garbled when tidy isn't on
 * (bug 5511) Fix URL-encoding of usernames in links on Special:Ipblocklist
 * (bug 6046) Update to Indonesian localisation (id) #15
+* (bug 5523) $wgNoFollowNsExceptions to allow disabling rel="nofollow" in
+  specially-selected namespaces.
+
 
 == Compatibility ==
 
index 9837bce..a5c394f 100644 (file)
@@ -1746,6 +1746,12 @@ $wgSearchForwardUrl = null;
  */
 $wgNoFollowLinks = true;
 
+/**
+ * Namespaces in which $wgNoFollowLinks doesn't apply.
+ * See Language.php for a list of namespaces.
+ */
+$wgNoFollowNsExceptions = array();
+
 /**
  * Specifies the minimal length of a user password. If set to
  * 0, empty passwords are allowed.
index f088faf..4fe385f 100644 (file)
@@ -734,10 +734,10 @@ class Linker {
        }
 
        /** @todo document */
-       function makeExternalLink( $url, $text, $escape = true, $linktype = '' ) {
+       function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null ) {
                $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
-               global $wgNoFollowLinks;
-               if( $wgNoFollowLinks ) {
+               global $wgNoFollowLinks, $wgNoFollowNsExceptions;
+               if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) {
                        $style .= ' rel="nofollow"';
                }
                $url = htmlspecialchars( $url );
index a3c3adf..cb6d692 100644 (file)
@@ -1190,7 +1190,7 @@ class Parser
                        # This means that users can paste URLs directly into the text
                        # Funny characters like &ouml; aren't valid in URLs anyway
                        # This was changed in August 2004
-                       $s .= $sk->makeExternalLink( $url, $text, false, $linktype ) . $dtrail . $trail;
+                       $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail;
 
                        # Register link in the output object.
                        # Replace unnecessary URL escape codes with the referenced character
@@ -1270,7 +1270,7 @@ class Parser
                                $text = $this->maybeMakeExternalImage( $url );
                                if ( $text === false ) {
                                        # Not an image, make a link
-                                       $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free' );
+                                       $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() );
                                        # Register it in the output object...
                                        # Replace unnecessary URL escape codes with their equivalent characters
                                        $pasteurized = Parser::replaceUnusualEscapes( $url );